/**
 * Copyright (c) 2010
 * Bert Young. UESTC. 
 */

#ifndef BERT_SERVERSOCKET_H
#define BERT_SERVERSOCKET_H

//#include "SocketConnection.h"
#include <string>
#include "Noncopyable.h"

class ServerSocket : private Noncopyable
{
	/**
	 * The server socket
	 */
	int sockfd;
	/**
	 * The epoll fd
	 */
	int epfd;
	/**
	 * Time out for accept
	 */
	static const int ACCEPT_TIMEOUT = 2100;
	/**
	 * Max connection in backup queue
	 */
	static const int LISTENQ = 2000;
public:
	/**
	 * Constructor
	 */
	ServerSocket();
	/**
	 * Destructor
	 */
	~ServerSocket();
	/**
	 * Create listen socket, bind , listen
	 */
	bool bind(const in_port_t port = 0 );
	/**
	 * Epoll for foreign connection
	 */
	int accept(struct sockaddr_in * client);
};

#endif

